<!DOCTYPE html>
<html lang='zh-CN'>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>签到管理</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <link href="js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://at.alicdn.com/t/font_1805932_ysrcp4y0uy9.css">
    <link rel="stylesheet" href="css/uploadImg.css">
</head>
<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <ul class="nav nav-tabs" role="tablist">
                        <li class="active"><a href="#rule" data-toggle="tab" onclick="dji('grid_data')">签到规则</a></li>
                        <li><a href="#sign" data-toggle="tab" onclick="dji('sign_data')">签到信息</a></li>
                        <li><a href="#record" data-toggle="tab" onclick="dji('record_data')">签到记录</a></li>
                    </ul>
                    <div class="tab-content">
                        <div id="rule" class="tab-pane fade active in" >
                            <form class="form-inline" method="post" id="searchForms">
                                <div class="form-group">
                                    <button class="btn btn-success btn_query btn-round" type="button" id="addBtn">添加签到规则</button>
                                </div>
                                <div class="form-group">
                                    <button class="btn btn-warning btn_query btn-round" type="button" id="editBtn">编辑签到规则</button>
                                </div>
                            </form>
                            <table id="grid_data"></table>
                        </div>

                        <div id="record" class="tab-pane fade">
                            <form class="form-inline" method="post" id="searchForm">
                                <div class="form-group">
                                    <label>会员ID:</label>
                                    <input type="text" class="form-control" name="memberId">
                                </div>
                                <div class="form-group">
                                    <button class="btn btn-info btn_query btn-round" type="button" id="searchFormBtn">查询</button>
                                </div>
                            </form>
                            <table id="record_data"></table>
                        </div>

                        <div id="sign" class="tab-pane fade">
                            <form class="form-inline" method="post" id="searchFormx">
                                <div class="form-group">
                                    <label>会员ID:</label>
                                    <input type="text" class="form-control" name="memberId">
                                </div>
                                <div class="form-group">
                                    <button class="btn btn-info btn_query btn-round" type="button" id="searcFormBtn">查询</button>
                                </div>
                            </form>
                            <table id="sign_data"></table>
                        </div>
                     </div>
                </div>

            </div>
        </div>
    </div>

    <!--  添加与编辑模态框 -->
    <div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <span>添加/编辑</span>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <div id="error_tips" style="color: #c9302c"></div>
                </div>
                <div class="modal-body">
                    <form id="addOrEditForm" method="post" enctype="multipart/form-data">
                        <div class="row">

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <input type="hidden" name="id">
                                    <span class="input-group-addon">第一天签到得多少积分</span>
                                    <input type="text" name="numOne" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第二天签到得多少积分</span>
                                    <input type="text" name="numTwo" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第三天签到得多少积分</span>
                                    <input type="text" name="numThree" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第四天签到得多少积分</span>
                                    <input type="text" name="numFour" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第五天签到得多少积分</span>
                                    <input type="text" name="numFive" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第六天签到得多少积分</span>
                                    <input type="text" name="numSix" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                            <div class="col-xs-12">
                                <div class="input-group m-b-10">
                                    <span class="input-group-addon">第七天签到得多少积分</span>
                                    <input type="text" name="numSeven" class="form-control" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^[0]+[0-9]*$/gi,'')">
                                </div>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary addSaveBtn" id="saveBtn">保存</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>

    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
    <!-- bootstrap表单验证插件 -->
    <script type="text/javascript" src="js/bootstrapvalidator/dist/js/bootstrapValidator.js"></script>
    <!-- bootstrap弹出框插件 -->
    <script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
    <!-- 表单填充插件 -->
    <script type="text/javascript" src="js/jquery-form/jquery.formloader.js"></script>
    <script type="text/javascript" src="js/zero2one/zero2one.curd.js"></script>
    <script type="text/javascript">

        //清除选中行
        function dji(tableId) {
            $('#'+tableId).bootstrapTable("uncheckAll");
        }

        //设置表头
        var columnsx = [
            {checkbox: true},
            {field: 'memberId',title: '会员ID'},
            {field: 'signTime',title: '最后一次签到时间'},
            {field: 'signCount',title: '连续签到次数'},
            {field: 'signAmount',title: '累计签到次数'}
        ];

        //加载列表信息
        zero2one.datagrid("sign_data", "/remote/sign/signList",function (params) {
            return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchFormx"));
        }, columnsx);

        //点击查询按钮重新加载页面数据
        $("#searcFormBtn").click(function () {
            $('#sign_data').bootstrapTable('refresh');
        });

        //设置表头
        var columnss = [
            {checkbox: true},
            {field: 'memberId',title: '会员ID'},
            {field: 'signTime',title: '会员签到时间'},
            {field: 'signPoint',title: '签到获得积分'}
        ];

        //加载列表信息
        zero2one.datagrid("record_data", "/remote/sign/recordList",function (params) {
            return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm"));
        }, columnss);

        //点击查询按钮重新加载页面数据
        $("#searchFormBtn").click(function () {
            $('#record_data').bootstrapTable('refresh');
        });

        //设置表头
        var columns = [
            {checkbox: true},
            {field: 'id',title: 'ID'},
            {field: 'numOne',title: '连续签到1天'},
            {field: 'numTwo',title: '连续签到2天'},
            {field: 'numThree',title: '连续签到3天'},
            {field: 'numFour',title: '连续签到4天'},
            {field: 'numFive',title: '连续签到5天'},
            {field: 'numSix',title: '连续签到6天'},
            {field: 'numSeven',title: '连续签到7天'}
        ];

        //加载列表信息
        zero2one.table("/remote/sign/ruleList", columns);

        //点击添加按钮弹出模态框
        zero2one.addModal();

        //点击编辑按钮弹出模态框
        zero2one.editModal();

        //点击保存按钮提交请求且提交前先执行表单验证
        $('#addOrEditForm').bootstrapValidator({
            fields: {
                numOne: {validators: {notEmpty: {message: '第一天签到积分不能为空'}}},
                numTwo: {validators: {notEmpty: {message: '第二天签到积分不能为空'}}},
                numThree: {validators: {notEmpty: {message: '第三天签到积分不能为空'}}},
                numFour: {validators: {notEmpty: {message: '第四天签到积分不能为空'}}},
                numFive: {validators: {notEmpty: {message: '第五天签到积分不能为空'}}},
                numSix: {validators: {notEmpty: {message: '第六天签到积分不能为空'}}},
                numSeven: {validators: {notEmpty: {message: '第七天签到积分不能为空'}}}
            }
        });
        zero2one.save("/remote/sign/addOrEdit");

    </script>
</div>
</body>
</html>
